package com.it.park.controller.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.it.park.client.service.SignService;
import com.it.park.constant.Constant;
import com.it.park.model.Sign;
import com.it.park.rms.client.model.User;

@Controller
@RequestMapping("/user/sign")
public class UserSignController {
	private String rootPath=Constant.USER_PATH;

	@Autowired
	private SignService signService;
	
	/*个人发表的签名集合*/
	@RequestMapping("signListByUserId")
	@ResponseBody
	public List<Sign> signListByUserId(HttpServletRequest request,HttpSession session){
			User user = (User) session.getAttribute("user");
			String startPosStr = request.getParameter("startPos");
			Map<String,Object> map =new HashMap<String,Object>();
			Integer startPos = 0;
			if(startPosStr != null){
				startPos = Integer.parseInt(startPosStr);
			}
			map.put("userId", user.getId());
			map.put("startPos",startPos);
			List<Sign>  signs = signService.selectByUserId(map);
			return signs;
	}
	
	/**
	 * 签名页面
	 */
	@RequestMapping("signList")
	public String signList(HttpServletRequest request,HttpSession session){
		return rootPath+"account/signLists";
	}
	
	
	
	/**
	 *单个动态查看 
	 */
	@RequestMapping("detail")
	public String detail(@RequestParam("id") Integer id,HttpServletRequest request){
		return rootPath+"moments/momentsDetail";
	}
	
	
}
